//
//  BRMInfoZeroTableViewCell.m
//  BrezzeSaaS
//
//  Created by macos on 14.3.22.
//  Copyright © 2022 Brezze GWG. All rights reserved.
//

#import "BRMInfoZeroTableViewCell.h"
#import "BRMHeaderTableViewCell.h"
#import "BRMInfoImgsTableViewCell.h"
#import "BRMInfoNoramlTableViewCell.h"
#import "BRMTimeSwitchTableViewCell.h"
#import "BRMDayTimeTableViewCell.h"

@implementation BRMInfoZeroTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.tableView.estimatedRowHeight = 44;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.tableView.backgroundColor = UIColorClear;
    self.contentView.backgroundColor = UIColor.qd_backgroundColorLighten;
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BRMHeaderTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BRMHeaderTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BRMInfoImgsTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BRMInfoImgsTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BRMInfoNoramlTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BRMInfoNoramlTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BRMTimeSwitchTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BRMTimeSwitchTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BRMDayTimeTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BRMDayTimeTableViewCell"];
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
}
    
#pragma mark - delegate --
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (self.sectionType == 3) {
        return 1 + 7;
    }
    if (self.sectionType == 2) {
        return 4;
    }
    return 2;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (self.sectionType == 3) {
        if (indexPath.row != 0) {
            BRMDayTimeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BRMDayTimeTableViewCell"];
            cell.top_bottom_h.constant = 90;// 90
            cell.timeView2.isAdd = YES;
            cell.timeView2.isEnble = NO;
            cell.timeView.isAdd = NO;
            
            return cell;
        }
        BRMTimeSwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BRMTimeSwitchTableViewCell"];
        
        return cell;
    }
    
    if (self.sectionType == 0) {


        if (indexPath.row == 0) {

            BRMHeaderTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:@"BRMHeaderTableViewCell"];


            return cell;
        }
        BRMInfoImgsTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:@"BRMInfoImgsTableViewCell"];


        return cell;
    }
    
    
    
    BRMInfoNoramlTableViewCell *cell  = [tableView dequeueReusableCellWithIdentifier:@"BRMInfoNoramlTableViewCell"];
    cell.isHasImg = NO;
    if (self.sectionType == 2) {
        cell.isHasImg = indexPath.row == 1 ;
    }
    cell.rightImg.hidden = self.sectionType == 1;

    return cell;

}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat cel_h  = 0;
    cel_h  = 200;
//    BRFAQModel *model = self.datas[indexPath.row];
//    if (model.cell_h != 0) {
//        return model.cell_h;
//    }
//
//    NSString *string = model.title;
//    cel_h = [string jk_heightWithFont:[UIFont br_fontM:14] constrainedToWidth:kScreenWidth - 134.] + 27.;
//    model.cell_h = cel_h;
    return  cel_h;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSIndexPath *indexP = [NSIndexPath indexPathForRow:indexPath.row inSection:self.sectionType];
    if (self.cellDidSelected) {
        self.cellDidSelected(indexP);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
